package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WarehouseDeliveryInformation;
import com.ruoyi.system.service.IWarehouseDeliveryInformationService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 发货信息Controller
 * 
 * @author ruoyi
 * @date 2024-01-06
 */
@Controller
@RequestMapping("/system/deliveryInformation")
public class WarehouseDeliveryInformationController extends BaseController
{
    private String prefix = "system/deliveryInformation";

    @Autowired
    private IWarehouseDeliveryInformationService warehouseDeliveryInformationService;

    @RequiresPermissions("system:deliveryInformation:view")
    @GetMapping()
    public String deliveryInformation()
    {
        return prefix + "/deliveryInformation";
    }

    /**
     * 查询发货信息列表
     */
    @RequiresPermissions("system:deliveryInformation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        startPage();
        List<WarehouseDeliveryInformation> list = warehouseDeliveryInformationService.selectWarehouseDeliveryInformationList(warehouseDeliveryInformation);
        return getDataTable(list);
    }

    /**
     * 导出发货信息列表
     */
    @RequiresPermissions("system:deliveryInformation:export")
    @Log(title = "发货信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        List<WarehouseDeliveryInformation> list = warehouseDeliveryInformationService.selectWarehouseDeliveryInformationList(warehouseDeliveryInformation);
        ExcelUtil<WarehouseDeliveryInformation> util = new ExcelUtil<WarehouseDeliveryInformation>(WarehouseDeliveryInformation.class);
        return util.exportExcel(list, "发货信息数据");
    }

    /**
     * 新增发货信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存发货信息
     */
    @RequiresPermissions("system:deliveryInformation:add")
    @Log(title = "发货信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        return toAjax(warehouseDeliveryInformationService.insertWarehouseDeliveryInformation(warehouseDeliveryInformation));
    }

    /**
     * 修改发货信息
     */
    @RequiresPermissions("system:deliveryInformation:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WarehouseDeliveryInformation warehouseDeliveryInformation = warehouseDeliveryInformationService.selectWarehouseDeliveryInformationById(id);
        mmap.put("warehouseDeliveryInformation", warehouseDeliveryInformation);
        return prefix + "/edit";
    }

    /**
     * 修改保存发货信息
     */
    @RequiresPermissions("system:deliveryInformation:edit")
    @Log(title = "发货信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        return toAjax(warehouseDeliveryInformationService.updateWarehouseDeliveryInformation(warehouseDeliveryInformation));
    }

    /**
     * 删除发货信息
     */
    @RequiresPermissions("system:deliveryInformation:remove")
    @Log(title = "发货信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(warehouseDeliveryInformationService.deleteWarehouseDeliveryInformationByIds(ids));
    }

    @PostMapping("/selectDeliveryInformation")
    @ResponseBody
    public AjaxResult selectDeliveryInformation(String ids)
    {
        return toAjax(warehouseDeliveryInformationService.selectDeliveryInformation(ids));
    }
}
